//
//  HXCollectionViewCell.m
//  ACMediaFrameExample
//
//  Created by 周佳 on 2019/2/20.
//  Copyright © 2019年 ArthurCao. All rights reserved.
//

#import "HXCollectionViewCell.h"
@interface HXCollectionViewCell ()

@property (nonatomic,strong)UIButton * deleteBtn;
@end

@implementation HXCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor redColor];
        self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        self.imageV.userInteractionEnabled = YES;
        [self.contentView addSubview:self.imageV];
        self.deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.deleteBtn.frame = CGRectMake(self.imageV.frame.size.width - 27, 0, 27, 27);
        [self.deleteBtn setBackgroundImage:[UIImage imageNamed:@"hxdeleteButton"] forState:UIControlStateNormal];
        [self.imageV addSubview:self.deleteBtn];
        [self.deleteBtn addTarget:self action:@selector(deleClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

-(void)setBgIm:(UIImage *)bgIm{
    if ([bgIm isEqual:[UIImage imageNamed:@"HXAddImage"]]) {
        self.deleteBtn.hidden = YES;
    }else{
        self.deleteBtn.hidden = NO;
    }
    self.imageV.image = bgIm;
}

-(void)deleClick:(UIButton *)sender{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"delegateImage" object:[NSNumber numberWithInteger:self.selectIndex]];
}
@end
